import 'package:flutter/material.dart';
import 'package:flutterproject/page/mine/children/assets/data/assets_detail_bean.dart';
import 'package:flutterproject/util/extension/extension_util.dart';
import 'package:flutterproject/util/margin_padding_util.dart';
import 'package:flutterproject/widget/image_extended.dart';
import 'package:flutterproject/widget/text/text_common.dart';
import 'package:get/get.dart';

class CardWidget extends StatelessWidget {
  final String image;
  final String title;
  final String value;
  final String value2;
  final String icon;

  /// 众商通的话需要显示金额余额啥的，直接传bean过来吧
  final AssetsDetailBean? bean;

  const CardWidget({
    super.key,
    required this.image,
    required this.title,
    required this.value,
    required this.value2,
    required this.icon,
    this.bean,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: Get.width,
      height: 210.width,
      padding: MarginPaddingUtil.only(top: 33, left: 52),
      margin:
          MarginPaddingUtil.fromLTRB(left: 20, top: 20, right: 20, bottom: 27),
      decoration: BoxDecoration(
        image: DecorationImage(
          image: AssetImage(image),
          fit: BoxFit.fill, // 完全填充
        ),
      ),
      child: Stack(
        clipBehavior: Clip.none,
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              TextCommon(
                title,
                size: 28.sp,
                color: Colors.white,
              ),
              25.heightBox,
              Row(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  TextCommon(
                    value,
                    size: 50.sp,
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                  ),
                  TextCommon(
                    '.$value2',
                    size: 36.sp,
                    color: Colors.white,
                  ),
                ],
              ),
              12.heightBox,
              if (bean != null)
                Row(
                  children: [
                    TextCommon(
                      "冻结",
                      size: 24.sp,
                      lineHeight: 35.sp,
                      color: Colors.white,
                    ),
                    32.widthBox,
                    TextCommon(
                      "${double.tryParse("${bean?.frozen ?? "0.0"}")}",
                      size: 24.sp,
                      lineHeight: 35.sp,
                      color: Colors.white,
                    ),
                    Spacer(),
                    TextCommon(
                      "可用",
                      size: 24.sp,
                      lineHeight: 35.sp,
                      color: Colors.white,
                    ),
                    32.widthBox,
                    TextCommon(
                      "${double.tryParse("${bean?.balance ?? "0.0"}")}",
                      size: 24.sp,
                      lineHeight: 35.sp,
                      color: Colors.white,
                    ),
                    46.widthBox,
                  ],
                )
            ],
          ),
          Positioned(
            right: -20.width,
            top: -55.width,
            child: ImageCommon(
              icon,
              size: 160.width,
            ),
          )
        ],
      ),
    );
  }
}
